<%@ page language="java" import="java.util.*" %>

<%-- Form Function --%>
<script type="text/javascript">

<%ResourceBundle resource = ResourceBundle.getBundle("Constant_en");%>
var dataStatus =  <%= resource.getString("cureplan.status") %>;
var strSelectDefault = "<%= resource.getString("project.select.default") %>";
    
    $(document).ready(function() {
        populateSelect($('#ddlStatus').get(0), dataStatus, strSelectDefault);
        $("#ddlStatus option[value='D']").remove();
        $("#formSearch").find("input, select").uniform();
        $("#btnReset").click(function(){
            populateSelect($('#ddlStatus').get(0), dataStatus, strSelectDefault);
            $("#ddlStatus option[value='D']").remove();
            $.uniform.update(" select ");
            return false});
        $("#formSearch").validate({
            submitHandler: function(form) {
                LoadDataGrid();
                //$(form).ajaxSubmit();
            }
        });
        
    });
</script>
<%-- End Form Function --%>

<%-- Dropdownlist --%>
<script type="text/javascript">

</script>
<%-- End Dropdownlist Function --%>

<%-- jQGrid Init --%>
<script type="text/javascript">
jQuery.extend($.fn.fmatter , {
    imageButtonFormatter : function imageButtonFormatter(cellvalue, options, rowdata) {
    return "<a href=\"javascript:ContentAjaxRequest('SRV/CurePlanProviderDetail?curePlanId=" + rowdata[0] + "', 'section #container')\" ><img src='<%=request.getContextPath()%>/images/view_icon.gif' /></a> ";
}
});
jQuery.extend($.fn.fmatter.imageButtonFormatter , {
    unformat : function(cellvalue, options) {
    return cellvalue;
}
});

</script>
<script type="text/javascript">
    $(function() {
        $("#grid").jqGrid({
            url:'<%=request.getContextPath()%>/SRV/CurePlanProviderList/LoadGrid'+"?txtDoctorID="+1, //DocID
            datatype: 'json',
            mtype: 'POST',
            colNames:['ID' ,'Customer Name' , 'Service Name' ,'Status', 'Select'],
            colModel:[
                {name:'ID',index:'id', width:55},
                {name:'userFullName',index:'mUser.name',width:150},
                {name:'serviceName',index:'srvCureservice.name'},
                {name:'status',index:'status', width:100},
                {name:'Detail',index:'Detail', align:'center', width:100, sortable:false,formatter:'imageButtonFormatter'}
            ],
            postData: {
            },
            rowNum:20,
            rowList:[20,40,60],
            height: 200,
            width: 940,
            rownumbers: true,
            pager: '#pager',
            sortname: 'id',
            viewrecords: true,
            sortorder: "asc",
            caption:"RequestList",
            emptyrecords: "${EmptyRecordGrid}",
            loadonce: false,
            //loadComplete: "",
            jsonReader : {
                root: "rows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems: true, //if 'false' will chage json reader format to 'name' require
                //cell: "cell",
                id: "0" //id: "id"
            }
        });
        $("#grid").jqGrid('navGrid','#pager',
        {edit:false,add:false,del:false,search:false},
        {
            sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'],
            closeOnEscape: true,
            multipleSearch: true,
            closeAfterSearch: true }
    );

    }
);
    //jQuery("#grid").setGridWidth(800, true)
</script>
<%-- End jQGrid Init --%>

<%-- jQGrid Search Function --%>
<script type="text/javascript">

    function LoadDataGrid(){
        var txtName_User = jQuery("#txtName_User").val();
        var txtName_CureService = jQuery("#txtName_CureService").val();
        var ddlStatus = jQuery("#ddlStatus").val();
        var txtDoctorID = 1; //Query Doctor ID From User
        jQuery("#grid").jqGrid('setGridParam'
        ,{url:"<%=request.getContextPath()%>/SRV/CurePlanProviderList/LoadGrid"
                +"?txtName_User="+txtName_User
                +"&txtName_CureService="+txtName_CureService
                +"&ddlStatus="+ddlStatus
                +"&txtDoctorID="+txtDoctorID
            ,page:1}).trigger("reloadGrid");
    }

</script>
<%-- End jQGrid Search Function --%>


<div class="grid_16">
    <!-- insert content here -->
    <form id="formSearch" class="form" action="" method="GET">
      <table class="bgTable">

            <tr >
                <td colspan="4" class="bgheader" ><h5>Search</h5></td>
            </tr>
            <tr >
                <td colspan="4" class="bgtop" >&nbsp;</td>
            </tr>
            <tr >
                <td  class="bgCellNormal">Customer Name ::&nbsp;</td>
              <td class="bgCellInput"><input type="text" name="txtName_User" id="txtName_User" class="" value=""   /></td>
                <td  class="bgCellNormal">Status ::&nbsp;</td>
              <td  class="bgCellInput"><select id="ddlStatus" name="ddlStatus" class="">
              </select>              </td>
          </tr>
            <tr>
                <td class="bgCellNormal" >Service Name ::&nbsp;</td>
              <td class="bgCellInput" ><input type="text" name="txtPrice" id="txtName_CureService" class="" value=""   /></td>
                <td class="bgCellNormal"  >&nbsp;</td>
              <td class="bgCellInput" >&nbsp;</td>
          </tr>
            <tr>
                <td colspan="4"  class="bgbutton">
                   <input type="reset" name="btnReset" id="btnReset" value="Reset" /> &nbsp;&nbsp;
                   <input type="submit" name="btnSubmit" id="btnSubmit" value="Search" />                </td>
            </tr>
        </table>
    </form>
    <br />
    <div id="content-placeholder">
        <div id="jqgrid">
            <table id="grid"></table>
            <div id="pager"></div>
        </div>
    </div>
</div>
